package com.SmileBreaker;

import java.util.Timer;

import android.content.Context;
import android.util.AttributeSet;
import android.view.SurfaceHolder;
import android.view.SurfaceHolder.Callback;
import android.view.SurfaceView;

public class GameStageView extends SurfaceView implements Callback {
	
	private GameStageViewTask viewTask;
	private Timer timer;

	public GameStageView(Context context, AttributeSet attrs) {
		super(context, attrs);
		
		SurfaceHolder holder = getHolder();
		holder.addCallback(this);

		timer = new Timer();
		viewTask = new GameStageViewTask(holder, context);
		setFocusable(true);
	}
	
	@Override
	public void surfaceCreated(SurfaceHolder arg0) {
		timer.schedule(viewTask, 0, 15);
	}
	
	@Override
	public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
	}

	@Override
	public void surfaceDestroyed(SurfaceHolder arg0) {
		timer.cancel();
	}

	public Timer getTimer() {
		return timer;
	}

	public GameStageViewTask getViewTask() {
		return viewTask;
	}
	
	
}
